package com.ss.android.article.common.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.util.SparseArrayCompat;
import com.ss.android.account.model.BaseUser;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.callback.SSCallback;
import com.ss.android.common.util.json.JsonUtil;
import com.ss.android.newmedia.BaseAppData;
import java.util.List;
import org.json.JSONObject;

public class User implements Parcelable, SSCallback {
    public static final Parcelable.Creator CREATOR;
    public boolean isBlocked;
    public boolean isBlocking;
    public boolean isFollowed;
    public boolean isFollowing;
    public boolean isFriend;
    public boolean isVerified;
    public String mAvatarUrl;
    public String mDesc;
    public int mFollowerCount;
    public int mFollowingCount;
    public GenderType mGender;
    public long mId;
    public String mMobile;
    @Deprecated public String mName;
    public List mRoleIconList;
    public String mScreenName;
    public String mVerifiedContent;

    static {
       CREATOR = new h();
    }

    public User() {

        CallbackCenter.addCallback(BaseAppData.callbackTypeUserStateChanged, ((SSCallback)this));
    }

    protected User(Parcel arg7) {
        boolean v1 = true;

        this.mId = arg7.readLong();
        boolean v0 = arg7.readByte() != 0 ? true : false;
        this.isFriend = v0;
        v0 = arg7.readByte() != 0 ? true : false;
        this.isBlocked = v0;
        v0 = arg7.readByte() != 0 ? true : false;
        this.isBlocking = v0;
        v0 = arg7.readByte() != 0 ? true : false;
        this.isFollowing = v0;
        v0 = arg7.readByte() != 0 ? true : false;
        this.isFollowed = v0;
        if(arg7.readByte() == 0) {
            v1 = false;
        }

        this.isVerified = v1;
        this.mAvatarUrl = arg7.readString();
        this.mDesc = arg7.readString();
        this.mScreenName = arg7.readString();
        this.mFollowingCount = arg7.readInt();
        this.mName = arg7.readString();
        this.mFollowerCount = arg7.readInt();
        this.mVerifiedContent = arg7.readString();
        this.mMobile = arg7.readString();
        this.mRoleIconList = arg7.createTypedArrayList(UserIconStruct.CREATOR);
    }

    public int describeContents() {
        return 0;
    }

    public Object onCallback(Object[] args) {
        Object v8 = null;
        int v7 = 2;
        int v6 = -1;
        boolean v2 = true;
        if((BaseAppData.callbackTypeUserStateChanged.equals(args[0])) && ((Long) args[1]).longValue() == this.mId) {
            Object v0 = args[v7];
            int v1 = ((Integer)((SparseArrayCompat)v0).get(1, Integer.valueOf(v6))).intValue();
            if(v1 >= 0) {
                boolean v1_1 = v1 > 0 ? true : false;
                this.isBlocking = v1_1;
            }

            int v0_1 = ((Integer)((SparseArrayCompat)v0).get(v7, Integer.valueOf(v6))).intValue();
            if(v0_1 < 0) {
                return v8;
            }

            if(v0_1 <= 0) {
                v2 = false;
            }

            this.isFollowing = v2;
        }

        return v8;
    }

    public BaseUser toBaseUser() {
        BaseUser v0 = new BaseUser(this.mId);
        v0.setIsBlocked(this.isBlocked);
        v0.setIsBlocking(this.isBlocking);
        v0.setIsFollowed(this.isFollowed);
        v0.setIsFollowing(this.isFollowing);
        return v0;
    }

    public String toSpipeUser() {
        JSONObject v0 = new JSONObject();
        android.support.design.a.a(v0, "user_id", Long.valueOf(this.mId));
        android.support.design.a.a(v0, "screen_name", this.mScreenName);
        android.support.design.a.a(v0, "avatar_url", this.mAvatarUrl);
        android.support.design.a.a(v0, "description", this.mDesc);
        android.support.design.a.a(v0, "is_blocked", Boolean.valueOf(this.isBlocked));
        android.support.design.a.a(v0, "is_blocking", Boolean.valueOf(this.isBlocking));
        android.support.design.a.a(v0, "is_followed", Boolean.valueOf(this.isFollowed));
        android.support.design.a.a(v0, "is_following", Boolean.valueOf(this.isFollowing));
        return JsonUtil.a(v0);
    }

    public void writeToParcel(Parcel arg7, int arg8) {
        int v1 = 1;
        arg7.writeLong(this.mId);
        int v0 = this.isFriend ? 1 : 0;
        arg7.writeByte(((byte)v0));
        v0 = this.isBlocked ? 1 : 0;
        arg7.writeByte(((byte)v0));
        v0 = this.isBlocking ? 1 : 0;
        arg7.writeByte(((byte)v0));
        v0 = this.isFollowing ? 1 : 0;
        arg7.writeByte(((byte)v0));
        v0 = this.isFollowed ? 1 : 0;
        arg7.writeByte(((byte)v0));
        if(!this.isVerified) {
            v1 = 0;
        }

        arg7.writeByte(((byte)v1));
        arg7.writeString(this.mAvatarUrl);
        arg7.writeString(this.mDesc);
        arg7.writeString(this.mScreenName);
        arg7.writeInt(this.mFollowingCount);
        arg7.writeString(this.mName);
        arg7.writeInt(this.mFollowerCount);
        arg7.writeString(this.mVerifiedContent);
        arg7.writeString(this.mMobile);
        arg7.writeTypedList(this.mRoleIconList);
    }
}

